package com.example.bookKeep.controller;


import cn.hutool.core.util.RandomUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.example.bookKeep.entity.Book;
import com.example.bookKeep.entity.Timu;
import com.example.bookKeep.request.BookListRequest;
import com.example.bookKeep.response.base.Result;
import com.example.bookKeep.service.BookService;
import com.example.bookKeep.service.FileService;
import com.example.bookKeep.service.TiMuService;
import com.example.bookKeep.vo.BookHomeVO;
import com.example.bookKeep.vo.StatisticsContainerVO;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;

@RestController
@RequestMapping("/api/timu")
@Slf4j
public class TiMuController {

    @Autowired
    private TiMuService tiMuService;

    @GetMapping("/list")
    public List<Timu> list() {
        List<Timu> list = tiMuService.list();
        List<Timu> timus = RandomUtil.randomEleList(list, 30);
        List<Timu> result = new ArrayList<>();
        List<Timu> tiankong = new ArrayList<>();
        for (Timu timu : timus) {
            if(!timu.getTimutype().equals("填空题")){
                result.add(timu);
            }else{
                tiankong.add(timu);
            }
        }
        result.addAll(tiankong);
        return result;
    }
}
